package com.chen.swagger.core;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SpringDocOpenApiConfiguration  {
    //openapi文档设置
    @Bean
    public OpenAPI getOpenApi(){
        return new OpenAPI()
                .info(new Info()
                        .title("陈-商城系统")
                        .description("这个是一个商城系统")
                        .version("1.0")
                        .license(new License().name("可行通行证")
                                .url("11111")))
                .externalDocs(new ExternalDocumentation()
                        .description("陈俊辉的博客")
                        .url("123456"));
    }
    //分组api设置
    @Bean
    public GroupedOpenApi getApiGroup(){
        return GroupedOpenApi.builder()
                .group("api")
                .pathsToMatch("/api/**")
                .build();
    }
    @Bean
    public GroupedOpenApi getAdminGroup(){
        return GroupedOpenApi.builder()
                .group("admin")
                .pathsToMatch("/admin/**")
                .build();
    }

}
